<?php
include_once 'usuarios_protoweb.php';

/**
 * @package Protoweb
 * @subpackage controller
 */
class Usuarios extends Usuarios_protoweb {

    public function __construct() {
        parent::__construct();
    } // end of method __construct()

    public function login() {
        $data['usuario']           = new Usuario();
        $data['usuario']->email    = $this->input->post('email');
        $data['usuario']->password = $this->input->post('password');

        if ($data['usuario']->login())
            redirect(base_url() . 'usuarios/userhome/' . $data['usuario']->id . '/');
        else
            redirect(base_url());
    } // end of method login()


    public function register() {
        $data['usuario']           = new Usuario();
        $data['usuario']->email    = $this->input->post('email-register');
        $data['usuario']->password = $this->input->post('password-register');

        if ($data['usuario']->save())
            redirect(base_url() . 'usuarios/userhome/' . $data['usuario']->id . '/');
        else
            redirect(base_url());
    } // end of method register()

    public function userhome($id) {
        $data['usuario'] = new Usuario($id);
        $this->smarty_parser->view("userhome.html", $data);
    } // end of method register()    

    public function index() {
        $this->smarty_parser->view("user_login_register.html", array());
    } // end of method index()
  
} // class Usuarios

/* End of file usuarios.php */
/* Location: ./system/application/controllers/usuarios.php */